<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../css/element.css" rel="stylesheet"/>
    <link href="../css/styleindex.css" rel="stylesheet"/>
    <style>
    .el-tabs__item.is-active{
      color: #058142;
    }.el-tabs__active-bar{
      background-color: #058142;
    }.el-tabs{
      background-color: #fff;
    }.el-input__inner{
      border: 0;
      font-size: 1rem;
      text-align: center;
    }.el-input__prefix{
      display: none;
    }.el-tabs__item{
      padding: 0 5px;
    }
    </style>
</head>
<body style="background:#EFF0F4;">

  <div class="mui-content">
    <div id="vm" class="x-examok" v-cloak>
      <div class="x-header-g" id="header">
        <a class="x-header-arrow" @click="api.closeWin()"></a>
        <div class="x-header-t">填报营业数据</div>
      </div>
      <!--  -->
      <div class="x-ico-month">
        <el-date-picker v-model="cardsmonth" type="date" placeholder="选择日" @change="getmonth" format="yyyy 年 MM 月 dd日" value-format="yyyyMMdd" :editable="notkey"></el-date-picker>
      </div>
      <!--  -->
      <div class="">

        <template>
          <el-tabs v-model="activeName" @tab-click="handleClick" stretch="true">
            <el-tab-pane label="堂食数据" name="first">
              <template>
                <el-table :data="tableData">
                  <el-table-column label="堂食时段" width="50" fixed>
                    <template slot-scope="scope">
                      {{scope.row.title}}
                    </template>
                  </el-table-column>
                  <el-table-column label="开台数" width="">
                    <template slot-scope="scope">
                      <div style="border:1px solid #058142;border-radius:.2rem;"><el-input v-model="scope.row.open_table" placeholder="请输入内容" type="number"></el-input></div>
                    </template>
                  </el-table-column>
                  <el-table-column label="用餐人数" width="">
                    <template slot-scope="scope">
                      <div style="border:1px solid #058142;border-radius:.2rem;"><el-input v-model="scope.row.eat_num" placeholder="请输入内容" type="number"></el-input></div>
                    </template>
                  </el-table-column>
                  <el-table-column label="堂食营收" width="">
                    <template slot-scope="scope">
                      <div style="border:1px solid #058142;border-radius:.2rem;"><el-input v-model="scope.row.turnover" placeholder="请输入内容" type="number"></el-input></div>
                    </template>
                  </el-table-column>
                  <!-- <el-table-column label="填报数据" width="">
                    <template slot-scope="scope">
                      <el-button type="text">编辑</el-button>
                    </template>
                  </el-table-column> -->
                </el-table>
                <div class="x-table-desc">填报人：{{onename}}</div>
                <div class="x-pro-gobtn" @click="isokone">提交</div>
              </template>
            </el-tab-pane>
            <el-tab-pane label="外卖数据" name="second">
              <template>
                <el-table :data="tableDatatwo">
                  <el-table-column label="堂食时段" width="50" fixed>
                    <template slot-scope="scope">
                      {{scope.row.title}}
                    </template>
                  </el-table-column>
                  <el-table-column label="外卖单数" width="">
                    <template slot-scope="scope">
                      <div style="border:1px solid #058142;border-radius:.2rem;"><el-input v-model="scope.row.order_num" placeholder="请输入内容" type="number"></el-input></div>
                    </template>
                  </el-table-column>
                  <el-table-column label="外卖营收" width="">
                    <template slot-scope="scope">
                      <div style="border:1px solid #058142;border-radius:.2rem;"><el-input v-model="scope.row.turnover" placeholder="请输入内容" type="number"></el-input></div>
                    </template>
                  </el-table-column>
                </el-table>
                <div class="x-table-desc">填报人：{{twoname}}</div>
                <div class="x-pro-gobtn" @click="isoktwo">提交</div>
              </template>
            </el-tab-pane>
            <el-tab-pane label="营业数据" name="third">
              <template>
                <div class="x-pro-pro2">
                  <div class="x-pro-row">
                    <div class="x-pro-label">当日营收营业额：</div>
                    <div class="x-pro-input">
                      <el-input placeholder="请输入内容" v-model="daynum1"></el-input>
                    </div>
                  </div>
                  <div class="x-pro-row">
                    <div class="x-pro-label">当日短期促销费：</div>
                    <div class="x-pro-input">
                      <el-input placeholder="请输入内容" v-model="daynum2"></el-input>
                    </div>
                  </div>
                  <div class="x-pro-row">
                    <div class="x-pro-label">当日会员增量：</div>
                    <div class="x-pro-input">
                      <el-input placeholder="请输入内容" v-model="daynum3"></el-input>
                    </div>
                  </div>
                  <div class="x-pro-row">
                    <div class="x-pro-label">当日会员结账次数：</div>
                    <div class="x-pro-input">
                      <el-input placeholder="请输入内容" v-model="daynum4"></el-input>
                    </div>
                  </div>
                  <div class="x-pro-row">
                    <div class="x-pro-label">当日储值办理次数：</div>
                    <div class="x-pro-input">
                      <el-input placeholder="请输入内容" v-model="daynum5"></el-input>
                    </div>
                  </div>
                </div>
                <div class="x-table-desc">填报人：{{thirdname}}</div>
                <div class="x-pro-gobtn" @click="isokthird">提交</div>

              </template>
            </el-tab-pane>
            <el-tab-pane label="能源数据" name="four">
              <template>
                <div class="" style="display:flex">
                  <div class="" width="160px">
                    <el-table :data="tableDatathird1" width="260">
                      <el-table-column label="设备名称" width="80" fixed>
                        <template slot-scope="scope">
                          设备{{scope.row.no}}
                        </template>
                      </el-table-column>
                      <el-table-column label="电表" width="100">
                        <template slot-scope="scope">
                          <div v-if="scope.row.checked" style="border:1px solid #058142;border-radius:.2rem;"><el-input v-model="scope.row.val" placeholder="请输入内容" type="number"></el-input></div>
                          <div v-else style="height:42px">-</div>
                        </template>
                      </el-table-column>
                    </el-table>
                  </div>
                  <div class="" width="160px">
                    <el-table :data="tableDatathird2" width="160">
                      <el-table-column label="水表" width="100">
                        <template slot-scope="scope">
                          <div v-if="scope.row.checked" style="border:1px solid #058142;border-radius:.2rem;"><el-input v-model="scope.row.val" placeholder="请输入内容" type="number"></el-input></div>
                          <div v-else style="height:42px">-</div>
                        </template>
                      </el-table-column>
                    </el-table>
                  </div>
                  <div class="" width="160px">
                    <el-table :data="tableDatathird3" width="160">
                      <el-table-column label="燃气" width="100">
                        <template slot-scope="scope">
                          <div v-if="scope.row.checked" style="border:1px solid #058142;border-radius:.2rem;"><el-input v-model="scope.row.val" placeholder="请输入内容" type="number"></el-input></div>
                          <div v-else style="height:42px">-</div>
                        </template>
                      </el-table-column>
                    </el-table>
                  </div>
                </div>

              </template>
              <div class="x-table-desc">填报人：{{fourname}}</div>
              <div class="x-pro-gobtn" @click="isokfour">提交</div>
            </el-tab-pane>
            <el-tab-pane label="销售数据" name="five">
              <template>
                <div class="x-pro-pro2" v-for="item in tableDatafive" :key="item.key">
                  <div class="x-pro-row">
                    <div class="x-pro-label">{{item.title}}：</div>
                    <div class="x-pro-input">
                      <el-input placeholder="请输入内容" v-model="item.total"></el-input>
                    </div>
                  </div>
                </div>
                <div class="x-table-desc">填报人：{{fivename}}</div>
                <div class="x-pro-gobtn" @click="isokfive">提交</div>
              </template>
            </el-tab-pane>
          </el-tabs>
        </template>
      </div>
    </div>
  </div>

  <script type="text/javascript" src="../script/vue.js"></script>
  <script type="text/javascript" src="../script/element.js"></script>
  <script type="text/javascript" src="../script/api.js"></script>
  <script type="text/javascript" src="../script/base.js"></script>
	<script>
apiready = function () {

  $api.fixStatusBar($api.byId('header'));


    //
    var vm = new Vue({
      el:'#vm',
      data(){
        return{
          cardsmonth:'',
          activeName: 'first',
          tableData:[],
          tableDatatwo:[],
          tableDatathird1:[],
          tableDatathird2:[],
          tableDatathird3:[],
          desc1:0,
          desc2:0,
          desc3:0,
          desc4:0,
          istype:'0',
          tableheader:[],
          tabletop:[
              {
                  'label':'工龄',
                  'property':'age'
              },{
                  'label':'人数',
                  'property':'n'
              }
          ],// 表头
          tableDatayead:[],
          itemKey:'',
          notkey:false,
          onename:'',
          twoname:'',
          thirdname:'',
          fourname:'',
          fivename:'',
          noget:0,
          daynum1:'',
          daynum2:'',
          daynum3:'',
          daynum4:'',
          daynum5:'',
          food1:'',
          food2:'',
          food3:'',
          food4:'',
          food5:'',
          tableDatafive:'',

        }
      },
      created:function() {
        var that=this;

      },
      mounted:function(){
        var that=this;
        //当前月份
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth()+1;
        var day = date.getDate();
        if(month<10){
          month = '' + 0 + month;
        }
        if(day<10){
          day = '' + 0 + day;
        }
        var toMonth = '' + year + month + day;
        that.cardsmonth = toMonth;
        that.chancedata = toMonth;
        that.getdatafirst()

      },
      methods: {
        //月份
        getmonth:function(val){
          var that = this;
          console.log(val);
          that.chancedata = val;
          if(that.istype=='0'){
            that.getdatafirst()
          }else if(that.istype=='1'){
            that.getdatatwo()
          }else if(that.istype=='2'){
            that.getdatathird()
          }else if(that.istype=='3'){
            that.getdatafour()
          }else if(that.istype=='4'){
            that.getdatafive()
          }

        },
        //选项卡
        handleClick(tab, event) {
          let id = event.target.getAttribute('id').split('-');
          let whitetab = id.join('').substring(3,9);
          let that = this;
          if(whitetab=='first'){//入职
            that.istype = '0';
            that.getdatafirst()
          }else if(whitetab=='second'){//离职
            that.istype = '1';
            that.getdatatwo()
          }else if(whitetab=='third'){//工龄
            that.istype = '2';
            that.getdatathird()
          }else if(whitetab=='four'){//工龄
            that.istype = '3';
            that.getdatafour()
          }else if(whitetab=='five'){//工龄
            that.istype = '4';
            that.getdatafive()
          }
        },
        //堂食
        getdatafirst:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/mgt/workContent',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                date:that.chancedata
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                that.tableData = ret.data.list;
                that.onename = ret.data.set_username;

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //外卖
        getdatatwo:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/mgt/takeContent',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                date:that.chancedata
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                that.tableDatatwo = ret.data.list;
                that.twoname = ret.data.set_username;

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //营业
        getdatathird:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/mgt/turnover',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                date:that.chancedata
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                // that.tableDatathird = ret.data.list;
                that.thirdname = ret.data.set_username;

                that.daynum1 = ret.data.list.today;
                that.daynum2 = ret.data.list.promote;
                that.daynum3 = ret.data.list.vip_num;
                that.daynum4 = ret.data.list.vip_pay;
                that.daynum5 = ret.data.list.save_num;
              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //能源
        getdatafour:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/mgt/device',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                date:that.chancedata
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                that.tableDatathird1 = ret.data.ammeter;
                that.tableDatathird2 = ret.data.water_meter;
                that.tableDatathird3 = ret.data.gas_meter;
                that.fourname = ret.data.set_username;

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //销售
        getdatafive:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/mgt/sale',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                date:that.chancedata
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                that.tableDatafive = ret.data.list;
                that.fivename = ret.data.set_username;
              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //堂食 提交
        isokone:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/mgt/setWorkContent',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                date:that.chancedata,
                data_json:that.tableData
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
                that.getdatafirst()

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //提交2
        isoktwo:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/mgt/setTakeContent',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                date:that.chancedata,
                data_json:that.tableDatatwo
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
                that.getdatatwo()

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //提交3
        isokthird:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/mgt/setTurnover',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                date:that.chancedata,
                today:that.daynum1,
                promote:that.daynum2,
                vip_num:that.daynum3,
                vip_pay:that.daynum4,
                save_num:that.daynum5
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
                that.getdatathird()

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //提交4
        isokfour:function(){
          var that = this;
          api.ajax({
            url:baseurl+'api/mgt/setDevice',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                date:that.chancedata,
                ammeter_json:that.tableDatathird1,
                water_json:that.tableDatathird2,
                gas_json:that.tableDatathird3
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
                that.getdatafour()

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //提交5
        isokfive:function(){
          var that = this;
          api.ajax({
            url:baseurl+'api/mgt/setSale',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                date:that.chancedata,
                data_json:that.tableDatafive
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
                that.getdatafive()

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
      }
    })
	}


	</script>
</body>
</html>
